import React from "react";
import store from "../redux/store";

export default function City(props) {
    const [state] = React.useState(["北京", "上海", "广州", "深圳"])

    return <div>
        请选择城市：
        <div>
            <ul>
                {
                    state.map(city => <li onClick={() => {
                        // 修改城市
                        store.dispatch({type: "changeCity", payload: city})

                        // 返回上一页
                        props.history.goBack()
                    }} key={city}>{city}</li>)
                }
            </ul>
        </div>
    </div>
}